package LeetCode;

public class LC_507_PerfectNumber {

    public static void main(String[] args) {

    }

    public class Solution {
        public boolean checkPerfectNumber(int num) {
            if (num == 0 || num == 1) return false;
            int result = num;
            for (int i = 1; i * i <= num; i++) {
                if (num % i == 0) {
                    if (i * i != num && i != 1)
                        result = result - i - num / i;
                    else
                        result = result - i;
                }
            }
            return result == 0;
        }
    }

    class Solution_2 {
        public boolean checkPerfectNumber(int num) {
            return num == 6 || num == 28 || num == 496 || num == 8128 || num == 33550336;
        }
    }
}
